//
//  YCNewCollectionCell.m
//  LOLBox
//
//  Created by mac on 15-3-26.
//  Copyright (c) 2015年 Honey. All rights reserved.
//

#import "YCNewCollectionCell.h"
#import "YCVideoModel.h"
#import "UIImageView+WebCache.h"

@interface YCNewCollectionCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UILabel *imgTime;
@property (weak, nonatomic) IBOutlet UILabel *length;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *yearDay;



@end

@implementation YCNewCollectionCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)fillCellWithModel:(YCVideoModel *)model
{
    [_imgView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"noimage_xiangqing"]];
//    _postTime.text = [self upTime:s];
    _name.text = model.name;

    _length.text = model.length;
    _imgTime.text = model.length;
    _yearDay.text = [self upTime:[NSString stringWithFormat:@"%@",model.time]];
    
    //加边框
    CALayer *layer = [self.imgView layer];
    layer.borderColor = [[UIColor grayColor] CGColor];
    layer.borderWidth = 1.2f;
}

- (NSString *)upTime:(NSString *)str
{
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[str floatValue]];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd";
    NSString *time = [formatter stringFromDate:date];
    
    // 3.显示日期
    return [NSString stringWithFormat:@"%@", time];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
